#include <iostream>
#include <vector>
#include <queue>

using namespace std;


/**
 * https://www.luogu.com.cn/problem/P1540
 */
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);

    int M,N;
    cin >> M >> N;

    vector<int> cached(1001, 0);
    queue<int> q;

    int lookups = 0;

    for(int i=0; i< N; i++){
        int x;
        cin >> x;
        if (cached[x] == 0){
            cached[x] = 1;
            lookups++;

            if (q.size() >= M){
                int removed = q.front();
                q.pop();
                cached[removed] = 0;
            }
            q.push(x);
        }
    }

    cout << lookups;


    return 0;   
}